<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
  <div id="Application">
    <my-container>
      组件内部
    </my-container>
    <my-container></my-container>
    <my-container2>
      <template #header>
        <h1>这里是头部元素</h1>
      </template>
      <template #main>
        <p>内容部分</p>
        <p>内容部分</p>
      </template>
      <template #footer>
        <p>这里是底部元素</p>
      </template>
    </my-container2>
  </div>

  <script>
    const { createApp, ref } = Vue;
    const App = createApp({})
    const containerComponent = {
      template: `<div style="border-style: solid; border-color: red; border-width: 10px;"><slot>插槽的默认内容</slot></div>`
    }
    App.component('my-container', containerComponent)
    const container2Component = {
      template: `<div>
        <slot name="header"></slot>
        <hr></hr>
        <slot name="main"></slot>
        <hr></hr>
        <slot name="footer"></slot>
        </div>`
    }
    App.component('my-container2', container2Component)
    App.mount("#Application");
  </script>
</body>
</html>